package com.shenmazong.controller;

import com.github.pagehelper.PageInfo;
import com.shenmazong.pojo.TbTaskChapter;
import com.shenmazong.service.TbTaskChapterService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 作业库章节
 */
@RestController
@RequestMapping("/taskChapter")
public class TbTaskChapterController {
    @Autowired
    TbTaskChapterService tbTaskChapterService;

    /**
     * 列表
     * @param listParamVo
     * @return
     */
    @PostMapping("/taskChapterList")
    public ResultResponse findTbTaskChapterList(@RequestBody ListParamVo listParamVo){
        Integer current = listParamVo.getCurrent();
        Integer size = listParamVo.getSize();
        Object taskChapter = listParamVo.getParamMap().get("taskChapter");
        PageInfo pageInfo=tbTaskChapterService.findTbTaskChapterList(current,size,taskChapter);
        return ResultResponse.SUCCESS(pageInfo);
    }

    /**
     * 章节添加
     * @param tbTaskChapter
     * @return
     */
    @PostMapping("/saveTaskChapter")
    public ResultResponse saveTaskChapter(@RequestBody TbTaskChapter tbTaskChapter){
        return tbTaskChapterService.saveTaskChapter(tbTaskChapter);
    }

    /**
     * 章节回显
     * @param tbTaskChapter
     * @return
     */
    @PostMapping("/echoTaskChapter")
    public ResultResponse echoTaskChapter(@RequestBody TbTaskChapter tbTaskChapter){
        return tbTaskChapterService.echoTaskChapter(tbTaskChapter);
    }

    /**
     * 章节修改
     * @param tbTaskChapter
     * @return
     */
    @PostMapping("/updateTaskChapter")
    public ResultResponse updateTaskChapter(@RequestBody TbTaskChapter tbTaskChapter){
        return tbTaskChapterService.updateTaskChapter(tbTaskChapter);
    }

    /**
     * 删除章节
     * @param tbTaskChapter
     * @return
     */
    @PostMapping("/delTaskChapter")
    public ResultResponse delTaskChapter(@RequestBody TbTaskChapter tbTaskChapter){
        return tbTaskChapterService.delTaskChapter(tbTaskChapter);
    }

    /**
     * 章节下拉
     * @return
     */
    @PostMapping("/findTaskChapter")
    public ResultResponse findTaskChapter(){
        return tbTaskChapterService.findTaskChapter();
    }


}
